p_height=2;
p_width=12;

output_name="/Volumes/Data/gSVN/ethernet-switch/paper/figures/3COM_accuracy_evaluation.eps"

my_dir="/Volumes/Data/gSVN/ethernet-switch/paper/plots/accuracy_evaluation/3COM/";

r_loss_rate_filename=paste(my_dir, "loss_rate_3COM_real.txt", sep="");
a_loss_rate_filename=paste(my_dir, "loss_rate_3COM_simplified.txt", sep="");
q_loss_rate_filename=paste(my_dir, "loss_rate_3COM_queue.txt", sep="");
r_lp_mean_filename=paste(my_dir, "lp_mean_3COM_real.txt", sep="");
a_lp_mean_filename=paste(my_dir, "lp_mean_3COM_simplified.txt", sep="");
q_lp_mean_filename=paste(my_dir, "lp_mean_3COM_queue.txt", sep="");
r_lp_std_filename=paste(my_dir, "lp_std_3COM_real.txt", sep="");
a_lp_std_filename=paste(my_dir, "lp_std_3COM_simplified.txt", sep="");
q_lp_std_filename=paste(my_dir, "lp_std_3COM_queue.txt", sep="");
r_tbl_mean_filename=paste(my_dir, "tbl_mean_3COM_real.txt", sep="");
a_tbl_mean_filename=paste(my_dir, "tbl_mean_3COM_simplified.txt", sep="");
q_tbl_mean_filename=paste(my_dir, "tbl_mean_3COM_queue.txt", sep="");
r_tbl_std_filename=paste(my_dir, "tbl_std_3COM_real.txt", sep="");
a_tbl_std_filename=paste(my_dir, "tbl_std_3COM_simplified.txt", sep="");
q_tbl_std_filename=paste(my_dir, "tbl_std_3COM_queue.txt", sep="");
AS_filename=paste(my_dir, "AS.txt", sep="");

r_loss_rate=scan(file=r_loss_rate_filename);
a_loss_rate=scan(file=a_loss_rate_filename);
q_loss_rate=scan(file=q_loss_rate_filename);
r_lp_mean=scan(file=r_lp_mean_filename);
a_lp_mean=scan(file=a_lp_mean_filename);
q_lp_mean=scan(file=q_lp_mean_filename);
r_lp_std=scan(file=r_lp_std_filename);
a_lp_std=scan(file=a_lp_std_filename);
q_lp_std=scan(file=q_lp_std_filename);
r_tbl_mean=scan(file=r_tbl_mean_filename);
a_tbl_mean=scan(file=a_tbl_mean_filename);
q_tbl_mean=scan(file=q_tbl_mean_filename);
r_tbl_std=scan(file=r_tbl_std_filename);
a_tbl_std=scan(file=a_tbl_std_filename);
q_tbl_std=scan(file=q_tbl_std_filename);
AS=scan(file=AS_filename);

#quartz();
postscript(output_name, height=p_height, width=p_width, horizontal=FALSE, onefile=TRUE);

#The four numbers in the call to par are the number of lines of text reserved on the bottom, left, top and right, respectively, ps: text size, mpg: margin size for title, axis label and axis
saved_par=par(mar=c(2.5,2.5,0.3,0.1)+0.1, ps=10, mgp=c(1.5, 0.5,0), mfrow=c(1,3));

#plot for loss_rate
plot(x=AS, y=r_loss_rate, col='blue', lty = 1, xlim = c(1100, 1900), ylim = c(0,1), type="b", ylab="Loss Rate", xlab="", pch=4);

points(x=AS, y=q_loss_rate, lty = 1, xaxt ="n", col='red', pch=0, type="b")

points(x=AS, y=a_loss_rate, lty = 1, xaxt ="n", col='black', pch=1, type="b")

legend('topleft', legend=c('Real Switch', 'Queueing Model', 'Simplified Queueing Model'), col=c('blue', 'red', 'black'), pch=c(4,0,1), bty='n');


#plot for loss episode
#y_lab=expression(paste("Average Time of Loss Episode(", mu, "s)", sep=""));
plotCI(x=AS, y=r_lp_mean, uiw=r_lp_std, col='blue', lty = 1, xlim = c(1100, 1900), ylim=c(0, 5), gap = 0, type="b", ylab="Loss Episode", xlab="Aggregated Sending Rate (Mb/s)", pch=4);

plotCI(x=AS, y=q_lp_mean, uiw=q_lp_std, lty = 1, xaxt ="n", gap = 0, add = TRUE, col='red', pch=0, type="b")

plotCI(x=AS, y=a_lp_mean, uiw=a_lp_std, lty = 1, xaxt ="n", gap = 0, add = TRUE, col='black', pch=1, type="b")


#plot for average time between loss
plotCI(x=AS, y=r_tbl_mean, uiw=r_tbl_std, col='blue', lty = 1, xlim = c(1100, 1900), ylim=c(0, 200), gap = 0, type="b", ylab="Time between Loss Episode", xlab="", pch=4);

plotCI(x=AS, y=q_tbl_mean, uiw=q_tbl_std, lty = 1, xaxt ="n", gap = 0, add = TRUE, col='red', pch=0, type="b")

plotCI(x=AS, y=a_tbl_mean, uiw=a_tbl_std, lty = 1, xaxt ="n", gap = 0, add = TRUE, col='black', pch=1, type="b")

par(saved_par);

dev.off()